package vcp.gui.forms.validators;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NameValidator {
	private Pattern pattern;
	private Matcher matcher;
	private String message=null;
	private static final String PATTERN = "^[a-z0-9_-]{3,15}$";
	public NameValidator(){
		pattern = Pattern.compile(PATTERN);
	}	
	public boolean validate(String txt){
		 
		  matcher = pattern.matcher(txt);
		  boolean res= matcher.matches();
		  if(!res)
			  message = "Wrong First Name..";
		  return matcher.matches();
	}
	public String getMessage(){
		return message;
	}
}
